# -*- coding: utf8 -*-
from google.appengine.ext import db

class Space(db.Model):
    """ 用户空间 """
    user = db.UserProperty()

class TaskGroup(db.Model):
    """ 任务分组 """
    # 用户
    user = db.UserProperty()
    # 名称
    name = db.StringProperty()
    # 创建时间
    create_date = db.DateProperty(auto_now_add = True)
    
    def __str__(self):
        return "TaskGroup(%s, %s)" % (user.name, name)

class Task(db.Model):
    """ 任务列表 """
    TASK_TODO = 'todo'
    TASK_DONE = 'done'
    TASK_DEPRECATE = 'deprecate'
    
    # 用户
    user = db.UserProperty()
    # 项目                
    name = db.TextProperty()
    #分组
    group = db.ReferenceProperty(reference_class = TaskGroup, collection_name='tasks')
    # 优先级
    priority = db.IntegerProperty(default=1)
    # 提交日期
    create_date = db.DateProperty(auto_now_add = True)
    # 完成日期
    end_date = db.DateProperty()
    # 状态ￗﾴￌﾬ
    status = db.StringProperty(default = TASK_TODO, 
                               choices=[TASK_TODO, TASK_DONE, TASK_DEPRECATE])
    # 相关笔记
    notes = db.ListProperty(db.Key)
    
    def __str__(self):
        return "Task(%s, %s)" % (user.name, item)

class Note(db.Model):
    " 笔记 "
    
    # 用户
    user = db.UserProperty()
    # 笔记标题                
    title = db.StringProperty()
    # 笔记内容             
    content = db.TextProperty()
    # 建立日期
    create_date = db.DateProperty()
    # 相关任务         
    tasks = db.ListProperty(db.Key)